#ifndef LOG_COMMON_H
#define LOG_COMMON_H
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <fstream>
#include <iostream>
#include <time.h>
#include <direct.h>

/* Debug log switch*/
#define SHOW_TIME (1)
/* LOG file config */
#define REP_CHR '_'
#define LOG_INIT_NAME "record"
#define LOG_EXT ".log"
#define LOG_DIR ".\\log\\"
/* Max allowed log info. length written */
#define LOG_MAX 255

extern std::fstream tstamp;

namespace fsl
{

class LogStream
{
private:
    bool busy; // Is file busy writing.
    bool file_only; // true: Only log in file. false: log in file and screen.
public:
    char *log_file;
    LogStream();
    LogStream(const char *);
    ~LogStream() {if (!this->log_file) delete log_file;}
    void setMode(bool b) {this->file_only = b;}
    LogStream & operator << (const char);
    LogStream & operator << (const int8_t);
    LogStream & operator << (const int16_t);
    LogStream & operator << (const int32_t);
    LogStream & operator << (const uint8_t);
    LogStream & operator << (const uint16_t);
    LogStream & operator << (const uint32_t);
    LogStream & operator << (const float);
    LogStream & operator << (const double);
    LogStream & operator << (const char *);
    LogStream & operator << (std::fstream &);
};
}

void dispTime(void);

#endif
/*EOF*/

